using System; namespace Example42 { class Point { private double x; private double y; public Point(double x, double y) { this.x = x; this.y = y; } public override string ToString() { return String.Format("({0:F5},{1:F5})", x, y); } public double X { get { return x; } set { x = value; } } public double Y { get { return y; } set { y = value; } } } /// /// Summary description for Class1. /// class Class1 { public static void printPoints(Point[] a) { /*for (int i = 0; i < a.Length; i++) { Console.WriteLine(a[i].ToString()); }*/ foreach (Point pt in a) { Console.WriteLine(pt.ToString()); } } /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Point[] pts = new Point[10]; Random randNumber = new Random(); for (int i = 0; i < pts.Length; i++) { pts[i] = new Point(10.0 * randNumber.NextDouble(), 100.0 * randNumber.NextDouble()); } printPoints(pts); for (int i = 0; i < pts.Length; i++) { pts[i].X = i; pts[i].Y = i+1; } printPoints(pts); foreach (Point pt in pts) { pt.X = 10; pt.Y = 100; } printPoints(pts); foreach (Point pt in pts) { pt.X = randNumber.NextDouble(); pt.Y = randNumber.NextDouble(); } printPoints(pts); } } }